package com.ll.gulimall.ware.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ll.common.to.SkuHasStockTo;
import com.ll.common.to.mq.OrderTo;
import com.ll.common.to.ware.WareLockTo;
import com.ll.common.utils.PageUtils;
import com.ll.gulimall.ware.entity.WareSkuEntity;
import com.ll.gulimall.ware.vo.FareAndAddressVo;
import com.ll.gulimall.ware.vo.WareLockResponseVo;
import com.ll.gulimall.ware.vo.WareLockVo;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 商品库存
 *
 * @author liliang
 * @email liliang@gmail.com
 * @date 2020-07-31 01:02:00
 */
public interface WareSkuService extends IService<WareSkuEntity> {

    PageUtils queryPage(Map<String, Object> params);

    void addStock(Long skuId, Long wareId, Integer skuNum);

    /**
     * 根据SkuIds 查询该商品是否有库存
     * @param skuIds
     * @return
     */
    List<SkuHasStockTo> hasStock(List<Long> skuIds);

    FareAndAddressVo freight(Long addrId);

    Boolean skuLock(WareLockVo wareLockVo);

    /**
     * 每一段时间扫描没有回滚的库存
     * @param message
     * @param lockTo
     * @param channel
     */
    void releaseWare(Message message, WareLockTo lockTo, Channel channel);

    /**
     * 订单超时直接释放库存
     * @param message
     * @param order
     * @param channel
     */
    void releaseWare(Message message, OrderTo order, Channel channel);
}


